package com.canaan.business.controller.pc.invoice;

import com.canaan.business.domain.invoice.WmsProStockApplyDetail;
import com.canaan.business.service.invoice.IWmsProStockApplyDetailService;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.core.page.TableDataInfo;
import com.canaan.common.enums.BusinessType;
import com.canaan.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 入库申请单明细Controller
 *
 * @author ruoyi
 * @date 2022-12-19
 */
@RestController
@RequestMapping("/invoice/proStockApplyDetail")
public class WmsProStockApplyDetailController extends BaseController
{
    @Resource
    private IWmsProStockApplyDetailService wmsProStockApplyDetailService;

    /**
     * 查询入库申请单明细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WmsProStockApplyDetail wmsProStockApplyDetail)
    {
        startPage();
        List<WmsProStockApplyDetail> list = wmsProStockApplyDetailService.selectWmsProStockApplyDetailList(wmsProStockApplyDetail);
        return getDataTable(list);
    }

    /**
     * 导出入库申请单明细列表
     */
    @Log(title = "入库申请单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsProStockApplyDetail wmsProStockApplyDetail)
    {
        List<WmsProStockApplyDetail> list = wmsProStockApplyDetailService.selectWmsProStockApplyDetailList(wmsProStockApplyDetail);
        ExcelUtil<WmsProStockApplyDetail> util = new ExcelUtil<WmsProStockApplyDetail>(WmsProStockApplyDetail.class);
        util.exportExcel(response, list, "入库申请单明细数据");
    }

    /**
     * 获取入库申请单明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsProStockApplyDetailService.selectWmsProStockApplyDetailById(id));
    }

    /**
     * 新增入库申请单明细
     */
    @Log(title = "入库申请单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsProStockApplyDetail wmsProStockApplyDetail)
    {
        return toAjax(wmsProStockApplyDetailService.insertWmsProStockApplyDetail(wmsProStockApplyDetail));
    }

    /**
     * 修改入库申请单明细
     */
    @Log(title = "入库申请单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsProStockApplyDetail wmsProStockApplyDetail)
    {
        return toAjax(wmsProStockApplyDetailService.updateWmsProStockApplyDetail(wmsProStockApplyDetail));
    }

    /**
     * 删除入库申请单明细
     */
    @Log(title = "入库申请单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsProStockApplyDetailService.deleteWmsProStockApplyDetailByIds(ids));
    }
}
